<?php

$game	=	$_GET['game'];

if (!file_exists('scripts/'.$game.'.php'))
{
	error_redirect('No such game: '.$game.'!',ERROR_GENERAL);
}

include('scripts/'.$game.'.php');

$maydownload	=	true;
if (isset($game_password[$game]))
{
	if ( strcmp($game_password[$game],$_POST['GamePassword']) != 0 )
	{
		$maydownload	=	false;
	}
	if ( isset($game_nopasswordafter[$game]) )
	{
		if ( time() > strtotime($game_nopasswordafter[$game]) )
		{
			$maydownload	=	true;
		}
	}
}
if (!$maydownload)
{
	error_redirect('Incorrect Password. You cannot download '.$game.'!',ERROR_GENERAL);
}

if (!file_exists('installer/'.$game . ' - Installer.exe'))
{
	error_redirect('No such installer: '.$game.'!',ERROR_GENERAL);
}

header('Content-Disposition: attachment; filename="'.str_replace(' ','%20',$game . ' - Installer.exe').'";');
header('Content-Type: application/force-download');
header('Content-Length: '.filesize('installer/'.$game . ' - Installer.exe'));

echo file_get_contents('installer/'.$game . ' - Installer.exe');
?>